//
//  DoctorApplyViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DoctorApplyViewController.h"

#import "DoctorAppleTableViewCell.h"

#import "DoctorApplyModel.h"

#import "NetWorkTool.h"

#import "DoctorMessageViewController.h"

@interface DoctorApplyViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)NSArray* myDoctorArray;


@end

@implementation DoctorApplyViewController

static NSString* reuserID = @"cell";
-(NSArray *)myDoctorArray
{
    if (_myDoctorArray == nil)
    {
        _myDoctorArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"DoctorApply.plist" ofType:nil]];
        
        NSMutableArray* array = [[NSMutableArray alloc]init];
        
        for (NSDictionary* dict in _myDoctorArray)
        {
            DoctorApplyModel* modle = [DoctorApplyModel modelWithDict:dict];
            
            [array addObject:modle];
        }
        _myDoctorArray = array;
    }
    return _myDoctorArray;

}

- (void)viewDidLoad
{
    [super viewDidLoad];

   
    
    self.navigationController.navigationBar.translucent = NO;
    
    UITableViewController* tableViewCon = [[UITableViewController alloc]init];
    
    [self.view addSubview:tableViewCon.tableView];
    
    tableViewCon.tableView.delegate = self;
    
    tableViewCon.tableView.dataSource = self;
    

  
    
    
    [tableViewCon.tableView registerClass:[DoctorAppleTableViewCell class] forCellReuseIdentifier:reuserID];
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return self.myDoctorArray.count;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    
    DoctorAppleTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:reuserID forIndexPath:indexPath];
    
    DoctorApplyModel* model = self.myDoctorArray[indexPath.row];
    
    cell.model = model;
    
    
    return cell;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 100;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    DoctorMessageViewController * controller = [[DoctorMessageViewController alloc]init];
    
    DoctorApplyModel* model = self.myDoctorArray[indexPath.row];
    
    controller.model = model;
    
   

   
    
    [self.navigationController pushViewController:controller animated:YES];
    
    
    
}




@end
